//加载vue模块
import Vue from 'vue';

//加载路由模块
import VueRouter from 'vue-router';


//加载、引入组件文件
import Login from '../views/Login.vue';
import Index from '../views/index.vue';
import Home from '../views/home.vue';
import Info from '../views/info.vue';
import My from '../views/my.vue';
import Detail from '../views/detail.vue';
import Appoint from '../views/appoint.vue';
import Infomore from '../views/infomore.vue';

//框架应用路由对象
Vue.use(VueRouter);

//配置路由（配置url访问地址）
const routes = [{
    path: '/',
    name: 'Login',
    // component: '../views/index.vue'
    component: Login,
    meta: {
        title: '登陆页',
        keepAlive: false //  不重新渲染
    }
}, {
    //配置首页
    path: '/index',
    name: 'index',
    //首页组件文件(写首页组件对象)
    component: Index,
    meta: {
        //页面标题
        title: '首页',
        keepAlive: true //不重复渲染，缓存
    }

}, {
    //配置首页
    path: '/home',
    name: 'home',
    //首页组件文件(写首页组件对象)
    component: Home,
    meta: {
        //页面标题
        title: '房源',
        keepAlive: true //不重复渲染，缓存
    }
}, {
    //配置首页
    path: '/info',
    name: 'info',
    //首页组件文件(写首页组件对象)
    component: Info,
    meta: {
        //页面标题
        title: '信息',
        keepAlive: true //不重复渲染，缓存
    }
}, {
    //配置首页
    path: '/my',
    name: 'my',
    //首页组件文件(写首页组件对象)
    component: My,
    meta: {
        //页面标题
        title: '我的',
        keepAlive: true //不重复渲染，缓存
    }
}, {
    //配置首页
    path: '/detail/:hid/:type',
    name: 'detail',
    //首页组件文件(写首页组件对象)
    component: Detail,
    meta: {
        //页面标题
        title: '房源详情',
        keepAlive: false //不重复渲染，缓存
    }
}, {
    //配置首页
    path: '/appoint',
    name: 'appoint',
    //首页组件文件(写首页组件对象)
    component: Appoint,
    meta: {
        //页面标题
        title: '预约',
        keepAlive: true //不重复渲染，缓存
    }
}, {
    //配置资讯页
    path: '/infomore',
    name: 'infomore',
    //首页组件文件(写首页组件对象)
    component: Infomore,
    meta: {
        //页面标题
        title: '资讯',
        keepAlive: true //不重复渲染，缓存
    }
}];

//实例化路由VueRouter,得到路由对象
const router = new VueRouter({
    // linkActiveClass:'active',
    linkExactActiveClass: 'active', //每个router-link组件会带一个active类名
    routes
});

//默认输出一次路由对象router
export default router;